/*
 * Copyright (c) 2021 Futurewei Technologies, Inc.
 *
 * clang2mpl is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan
 * PSL v2. You may obtain a copy of Mulan PSL v2 at:
 *
 *     http://license.coscl.org.cn/MulanPSL2
 *
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY
 * KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
 * NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. See the
 * Mulan PSL v2 for more details.
 */
// RUN: %clang2mpl --ascii --verify %s -- --target=aarch64-linux-elf
// RUN: cat %m | %FileCheck %s

void foo(int a, float b, double c, char *d) {
  // CHECK: LOC 2 [[# @LINE + 2 ]]{{$}}
  // CHECK-NEXT: if (ne i32 i32 (dread i32 %a, constval i32 0))
  if (a) { }

  // CHECK: LOC 2 [[# @LINE + 2 ]]{{$}}
  // CHECK-NEXT: if (ne i32 f32 (dread f32 %b, constval f32 0f))
  if (b) { }

  // CHECK: LOC 2 [[# @LINE + 2 ]]{{$}}
  // CHECK-NEXT: if (ne i32 f64 (dread f64 %c, constval f64 0))
  if (c) { }

  // CHECK: LOC 2 [[# @LINE + 2 ]]{{$}}
  // CHECK-NEXT: if (ne i32 a64 (dread a64 %d, constval a64 0))
  if (d) { }

  // CHECK: LOC 2 [[# @LINE + 2 ]]{{$}}
  // CHECK-NEXT: while (ne i32 i32 (dread i32 %a, constval i32 0))
  while (a) { }

  // CHECK: LOC 2 [[# @LINE + 2 ]]{{$}}
  // CHECK-NEXT: while (ne i32 f32 (dread f32 %b, constval f32 0f))
  while (b) { }

  // CHECK: LOC 2 [[# @LINE + 2 ]]{{$}}
  // CHECK-NEXT: while (ne i32 f64 (dread f64 %c, constval f64 0))
  while (c) { }

  // CHECK: LOC 2 [[# @LINE + 2 ]]{{$}}
  // CHECK-NEXT: while (ne i32 a64 (dread a64 %d, constval a64 0))
  while (d) { }

  // CHECK: LOC 2 [[# @LINE + 2 ]]{{$}}
  // CHECK-NEXT: while (ne i32 i32 (dread i32 %a, constval i32 0))
  for (; a;) { }

  // CHECK: LOC 2 [[# @LINE + 2 ]]{{$}}
  // CHECK-NEXT: while (ne i32 f32 (dread f32 %b, constval f32 0f))
  for (; b;) { }

  // CHECK: LOC 2 [[# @LINE + 2 ]]{{$}}
  // CHECK-NEXT: while (ne i32 f64 (dread f64 %c, constval f64 0))
  for (; c;) { }

  // CHECK: LOC 2 [[# @LINE + 2 ]]{{$}}
  // CHECK-NEXT: while (ne i32 a64 (dread a64 %d, constval a64 0))
  for (; d;) { }

  // CHECK: LOC 2 [[# @LINE + 3 ]]{{$}}
  // CHECK-NEXT: dowhile {
  // CHECK-NEXT: } (ne i32 i32 (dread i32 %a, constval i32 0))
  do { } while (a);

  // CHECK: LOC 2 [[# @LINE + 3 ]]{{$}}
  // CHECK-NEXT: dowhile {
  // CHECK-NEXT: } (ne i32 f32 (dread f32 %b, constval f32 0f))
  do { } while (b);

  // CHECK: LOC 2 [[# @LINE + 3 ]]{{$}}
  // CHECK-NEXT: dowhile {
  // CHECK-NEXT: } (ne i32 f64 (dread f64 %c, constval f64 0))
  do { } while (c);

  // CHECK: LOC 2 [[# @LINE + 3 ]]{{$}}
  // CHECK-NEXT: dowhile {
  // CHECK-NEXT: } (ne i32 a64 (dread a64 %d, constval a64 0))
  do { } while (d);
}
